function Check(rules){
    this.allPromise=[];
    let _this=this;
    for (let i = 0; i < rules.length; i++) {
        rules[i].domElement.onblur= function () {
                 new Promise((resolve, reject) => {
                if (rules[i].regex.test(this.value)) {
                    if(rules[i].resMethod){
                        rules[i].resMethod(resolve,reject);
                    }
                    resolve();
                }else {
                    rules[i].rejMethod();
                    reject(new Error(rules[i].Msg));
                }
            }).catch(()=>{})
        }
    }
    this.checkAll=function (resMethod,rejMethod){
        for (let i = 0; i < rules.length; i++) {
                _this.allPromise[i] = new Promise((resolve, reject) => {
                    if (rules[i].regex.test(rules[i].domElement.value)) {
                        if(rules[i].resMethod){
                            rules[i].resMethod(resolve,reject);
                        }
                        resolve();
                    }else {
                        rules[i].rejMethod();
                        reject(new Error(rules[i].Msg));
                    }
                }).catch(()=>{})
            }
        Promise.all(this.allPromise).then(()=>{
            resMethod();
        },(error)=>{
            rejMethod(error);
        });
    }
}